import { Notify } from 'vant';
export class Tools {
    static getStorage(_key) {
        return localStorage.getItem(_key);
    }
    static setStorage(_key, _val) {
        return localStorage.setItem(_key, _val);
    }
    static removeStorage(_key) {
        return localStorage.removeItem(_key)
    }
    static clearStorage() {
        return localStorage.clear();
    }
    static showMessage(message = "提示", type = "success") {
        Notify({ message, type });
    }
    static verifyToken() {//对token进行验证
        return this.getStorage("GossipAccessToken");
    }
    static setToken(_token) {
        this.setStorage("GossipAccessToken", _token)
    }
    static delToken(){ // 清除Token
        this.removeStorage("GossipAccessToken");
    }
    static getImageUrl(name) { // 动态加载图片
        return new URL(`./dir/${name}`, import.meta.url).href
    }
    static filterArr(_arr,...arg){ // 满足条件的数组
        return _arr.filter(item=>item[arg[0]]==arg[1]);
    }
    static filterArrVal(_arr,...arg){ // 满足条件的数组
        try {
            return (this.filterArr(_arr,arg[0],arg[1]))[0][arg[2]];
        }
        catch(err){
            throw Error('过滤传递参数不正确!'+err)
        }
    }
}

